<include file="public/header"/>
<link href="__TMPL__/public/assets/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link rel="stylesheet" href="__STATIC__/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css">

<style>
    table tr th,table tr td {text-align: center}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>公海列表</h5>
                    <div style="float: right;">
                        <!-- <a  class="btn btn-w-m btn-info" href="{:url('privateCreate')}">创建客户</a> -->
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <!--  <div class="col-sm-5 m-b-xs">
                           <select class="input-sm form-control input-s-sm inline">
                               <option value="0">选择品类</option>

                               <option value=""></option>

                           </select>
                         </div>  -->
                        <!--<form action="" method="post">
                           <div class="col-sm-6 m-b-xs">
                           <div data-toggle="buttons" class="btn-group">
                             <label class="btn btn-sm btn-white" style="width: 80px">
                               <input type="radio" id="option1" name="options" style="width: 80px">待财审</label>
                               <label class="btn btn-sm btn-white active" style="width: 80px">
                                 <input type="radio" id="option2" name="options" style="width: 80px">待审核</label>
                                 <label class="btn btn-sm btn-white" style="width: 80px">
                                   <input type="radio" id="option3" name="options" style="width: 80px">待定版</label>
                                   <label class="btn btn-sm btn-white" style="width: 80px">
                                     <input type="radio" id="option3" name="options" style="width: 80px">待下载</label>
                                     <label class="btn btn-sm btn-white" style="width: 80px">
                                       <input type="radio" id="option3" name="options" style="width: 80px">待发货</label>
                                       <label class="btn btn-sm btn-white" style="width: 80px">
                                         <input type="radio" id="option3" name="options" style="width: 80px">已驳回</label>
                                       </div>
                                     </div>
                                   </form> -->

                        <form action="" method="get">
                            <div class="col-sm-2" style="float: right;">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入发布者姓名" name="name" class="input-sm form-control">
                                    <span class="input-group-btn">
                                              <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
                                    </span>
                                    &emsp;
                                    <span class="input-group-btn">
                                         <a href="{:url('publicList')}" class="btn btn-sm btn-warning ">清空</a>
                                    </span>
                                </div>

                            </div>
                            <div class="col-sm-1" style="float: right;">
                                <div class="form-group">

                                    <select name="from"  class="form-control"  >
                                        <option value="-1">客户来源</option>
                                        <option value="1">自主开发</option>
                                        <option value="2">主动联系</option>
                                        <option value="3">公司派单</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-4" style="float: right;">
                                <div class="input-group">

                                    <label class="col-sm-3 control-label" style="top:10px;text-align: right">发布时间:</label>
                                    <div class="col-sm-4">
                                        <input id="addtime" name="start_time" type="text" class="form-control input-sm" placeholder="开始时间" value="{$start_time ?? ''}">
                                    </div>
                                    <!--div class="col-sm-1" style="top:10px">
                                        <span class="from-comtrol">-</span></div>-->
                                    <div class="col-sm-4">
                                        <input id="endtime" name="end_time" type="text" class="form-control input-sm" placeholder="结束时间" value="{$end_time ?? ''}">
                                    </div>
                                </div>

                            </div>

                        </form>
                        <div class="col-sm-8">
                            <div class="input-group" >
                                <!-- <button class="btn btn-sm btn-primary" onclick="export_data()">导出数据</button>
                                &emsp;&emsp;&emsp;&emsp;-->
                                <button class="btn btn-sm btn-success" onclick="go_private()">转到私海</button>
                                &emsp;&emsp;&emsp;&emsp;
                                <!--<a class="btn btn-sm btn-primary"  href="{:url('sendPublicSms')}"  >发送短信</a>-->
                            </div>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th></th>
                                <th>序号</th>
                                <th>客户名称</th>
                                <th>客户等级</th>
                                <th>客户意向</th>
                                <th>客户来源</th>
                                <th>发布者</th>
                                <th>发布时间</th>
                                <th>领取人</th>
                                <th>维护时间</th>
                                <th>客户类别</th>
                                <th>客户状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="list" id="vo">
                            <tr>
                                <td><input type="checkbox"  class="i-checks" name="input" value="{$vo.id}" <if condition="$vo.is_public eq 0"> disabled="disabled"</if>></td>
                                <td>{$vo.id}</td>
                                <td>{$vo.name}</td>
                                <td>{$vo.level}</td>
                                <td>{$vo.yixiang}</td>
                                <td>{$vo.from}</td>
                                <td>{$vo.entry_name}</td>
                                <td>{$vo.entry_time|date='Y-m-d H:i'}</td>
                                <td>
                                    <if condition="$vo['is_public'] eq 1">
                                    暂无
                                    <else />
                                    {$vo.ling_name}
                                    </if>
                                </td>
                                <td>{$vo.last_time|date='Y-m-d H:i'}</td>
                                <td>
                                    <if condition="$vo['is_public'] eq 1">
                                    <a data-toggle="modal"  href="javascript:;" ><span class="badge badge-warning">公海客户</span></a>
                                    <else />
                                    <a data-toggle="modal"  href="javascript:;" ><span class="badge badge-danger">私海客户</span></a>
                                    </if>
                                </td>
                                <td>
                                    <if condition="$vo['status'] eq 0">
                                    <a data-toggle="modal"  href="javascript:;" onclick="lingqu({$vo.id})"><span class="badge badge-primary">可领取</span></a>
                                    <else />
                                    <a data-toggle="modal"  href="JavaScript:;" ><span class="badge badge-danger">维护中</span></a>
                                    </if>
                                </td>
                                <td>
                                    <a href="{:url('message',array('id'=>$vo['id']))}" title="查看"><span class="label label-warning">查看</span></a>&emsp;
                                    <a href="javascript:;" title="删除" onclick="delcustomer({$vo['id']})"><span class="label label-danger">删除</span></a>
                                </td>
                            </tr>
                            </volist>
                            </tbody>
                        </table>
                        <div style="float: right;line-height: 5.5;">
                            总客户数量<span style="color: red;">{$count}</span>位&emsp;
                            <div id="pages" style="float: right;margin-left: 50px;">{$page}</div>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
</div>

<div id="modal-form_yundan" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 b-r">
                        <h3 class="m-t-none m-b">添加维护记录：</h3>
                        <form role="form" action="{:url('addRow')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-3 control-label" style="text-align: right;">客户意向：</label>
                                <div class="col-sm-9">
                                    <select name="yixiang" id="" class="form-control">
                                        <option value="-1">待定</option>
                                    </select>
                                </div>
                                <label class="col-sm-3 control-label" style="margin-top: 10px;text-align: right;">维护记录：</label>
                                <div class="col-sm-9" style="margin-top: 10px;margin-bottom: 30px;">
                                    <textarea name="content" id="" cols="30" rows="10" style="resize: none" class="form-control"></textarea>
                                    <input type="hidden" id="orderid_yun" name="cust_id" value="">
                                </div>
                            </div>
                            <div>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>提交</strong>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__TMPL__/public/assets/js/jquery.min.js?v=2.1.4"></script>
<script src="__TMPL__/public/assets/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__TMPL__/public/assets/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__TMPL__/public/assets/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__TMPL__/public/assets/js/plugins/layer/layer.min.js"></script>
<script src="__TMPL__/public/assets/js/hplus.min.js?v=4.0.0"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/contabs.min.js"></script>
<script src="__TMPL__/public/assets/js/plugins/pace/pace.min.js"></script>
<script src="__TMPL__/public/assets/js/content.min.js"></script>
<!-- Peity -->
<script src="__TMPL__/public/assets/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__STATIC__/js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<!-- iCheck -->
<script src="__TMPL__/public/assets/js/plugins/iCheck/icheck.min.js"></script>
<script src="__TMPL__/public/assets/js/plugins/sweetalert/sweetalert.min.js"></script>



<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

        $("[name='from']").find("[value='{$from ?? '-1'}']").attr("selected", true);

        $('#addtime').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd ',
            todayBtn:'linked',
            weekStart: 1,
            todayHighlight:true,
            initialDate:new Date(),
        });

        $('#endtime').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd ',
            todayBtn:'linked',
        });
    });


</script>
<script>
    function getInfo(id)
    {
        $.post('{url("admin/clothes/uploadZip")}', {id: id}, function(data) {
            if(data == 3){
                swal({
                    title: "权限不足",
                    text: "",
                    type: "error"
                });
                $('#modal-form').css('display','none');
            }
        });
        $("#order_id").val(id);
        $('#orderid_yun').val(id);
    }
</script>
<script>
    // 转移到私海的方法
    function go_private()
    {
        var attr = '';
        $.each($('input:checkbox'),function(){
            if(this.checked){
                attr += $(this).val()+',';
            }
        });
        attr=attr.substring(0,attr.length-1);
        if(attr.length<1)/*说明没有选择数据*/
        {
            swal({
                title: "请选择转移信息",
                text: "",
                type: "error",
            });
        }else{
            swal({
                title: "确定要转移到私海?",
                text: "确认将开始跟踪该客户!",
                type: "warning",
                showCancelButton: true,
                confirmButtonText: "确认",
                cancelButtonText: '取消',
                closeOnConfirm: false
            }, function(){
                window.location.href = '/admin/customer/goPrivate/attr/'+attr;
                //alert(123);

            });
        }
    }
    /*领取单个客户*/
    function lingqu(id)
    {
        swal({
            title: "确定要转移到私海?",
            text: "确认将开始跟踪该客户!",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "确认",
            cancelButtonText: '取消',
            closeOnConfirm: false
        }, function(){
            window.location.href = '/admin/customer/goPrivate/attr/'+id;
            //alert(123);

        });
    }
    /*分配客户到个人*/
    function go_fenpei()
    {
        var attr = '';
        $.each($('input:checkbox'),function(){
            if(this.checked){
                attr += $(this).val()+',';
            }
        });
        attr=attr.substring(0,attr.length-1);
        if(attr.length<1)/*说明没有选择数据*/
        {
            swal({
                title: "请选择分配信息",
                text: "",
                type: "error",
            });
        }else{
            $('#fenpei').attr('href','#modal-form_yundan');
        }
    }
</script>
<script>
    function delcustomer(id)
    {
        swal({
            title: "确定要删除数据?",
            text: "确认将删除该条数据!",
            type: "warning",
            showCancelButton: true,
            confirmButtonText: "确认",
            cancelButtonText: '取消',
            closeOnConfirm: false
        }, function(){
            $.post('{:url("deleteCustomer")}', {'id':id}, function(data) {
                if(data.sta == -1 ){
                    swal({
                        title: "权限不足",
                        text: "",
                        type: "error"
                    });
                }else if(data.sta == 1){
                    swal({
                        title: "删除成功",
                        text: "",
                        type: "success"
                    });
                    window.location.reload();
                }else{
                    swal({
                        title: "删除失败",
                        text: "",
                        type: "error"
                    });
                }
            });
        });
    }
</script>
</body>
</html>